<div ng-controller="SignAuthCtrl">
  <div class="panel panel-default">
 	 <div class="panel-body" style="padding-top: 0;padding-bottom: 0;">
 		<div class="nav navbar-nav m-t">
 			<a ui-sref="app.sys.user({page:'{{$state.params.page}}'})" ><span style="background-color: #e0e0e0; text-align: center;"><i class="glyphicon glyphicon-arrow-left" style="height:30px;width:30px; "></i></span></a> 	            
            <span><b>系统设置</b></span>
            <i class="fa fa-angle-right" style="font-size:20px"></i>
            <span><b>用户管理</b> </span>
            <i class="fa fa-angle-right" style="font-size:20px"></i>
            <span><b>分配权限</b></span> 
         </div>
        <!-- nabar right -->
        <ul class="nav navbar-nav navbar-right">          
          <li class="dropdown" dropdown>
            <a href class="dropdown-toggle clear" dropdown-toggle>
              <span class="thumb-sm avatar pull-right m-t-n-sm m-b-n-sm m-l-sm">
                <img src="img/a0.jpg" alt="...">
                <i class="on md b-white bottom"></i>
              </span>
              <span class="hidden-sm hidden-md"><b>{{namedata}}</b></span> <b class="caret"></b>
            </a>
            <!-- dropdown -->
            <ul class="dropdown-menu animated fadeInRight w">  
              <li>
                <a ui-sref="app.user.info">用户信息</a>
              </li>       
              <li class="divider"></li>
              <li>
                <a ui-sref="access.signin" ng-click="logout()">登出</a>
              </li>
            </ul>
            <!-- / dropdown -->
          </li>
        </ul>
 	</div>
</div>
<div class="panel panel-default m-t-n-md" >
  <div class="panel-body">
    <div class="m-t" style="font-weight: bold;font-size: 18px;">
      角色分配
    </div>
    <div class="row m-t-md">
      <div class="col-md-4" ng-repeat="aaData in aaData">
        <div style="font-size: 16px">
          <input type="checkbox" value="{{aaData.role_id}}" name="cbx" ng-if="aaData.has_right==true" checked="">
          <input type="checkbox" value="{{aaData.role_id}}" name="cbx" ng-if="aaData.has_right==false">
          <span class="m-l-xs">{{aaData.role_name}}</span>          
        </div>        
      </div>      
    </div>
    <div class="m-t-xl">      
        <div style="font-weight: bold;font-size: 18px;">
          楼层分配
        </div>       
        <table class="table m-t" style="font-size: 14px">
            <tr>
              <th>请选择学校</th>
              <th>请选择类型</th>
              <th>请选择楼号</th>
              <th>请选择楼层</th>
              <th>请选择单元</th>
              <th></th>
            </tr>
            <tr>
              <td>
                <select class="form-control" ng-model="b.school_name" ng-options="key as key for (key,value) in mmData" ng-change="b.buildingtype='';b.building_name='';b.layer_name='';" >
                  <option value="">--请选择学校--</option>                 
                </select>
              </td>
              <td>
                <select class="form-control" ng-model="b.buildingtype"  ng-change="b.building_name='';b.layer_name='';">
                  <option value="">--请选择类型--</option>
                  <option ng-if="key!='school_id'&&key!='school_name'&&key!='undefined'&&key!=''" ng-repeat="(key,value) in mmData[b.school_name]" value="{{key}}+{{mmData[b.school_name].school_id}}">{{key}}</option >
                </select>
              </td>
              <td>
                <select class="form-control" ng-model="b.building_name" ng-options="key as key for (key,value) in mmData[b.school_name][b.buildingtype.split('+')[0]]"  ng-change="getrooms(mmData[b.school_name][b.buildingtype.split('+')[0]][b.building_name].campus_id) ">
                  <option value="">--请选择楼号--</option>                                  
                </select>
              </td>
              <td>
                <select class="form-control" ng-model="b.layer_name" >
                  <option value="">--请选择楼层--</option>
                  <option value="{{mmData[b.school_name][b.buildingtype.split('+')[0]][b.building_name].campus_id}}+所有层">所有层</option>
                  <option ng-if="value!='所有层'"  ng-repeat="(key,value) in mmData[b.school_name][b.buildingtype.split('+')[0]][b.building_name].layers" value="{{value.layer_name}}+{{mmData[b.school_name][b.buildingtype.split('+')[0]][b.building_name].campus_id}}+{{value.layer_id}}">                
                    {{value.layer_name}}
                  </option>
                  
                </select>
              </td>
              <td>
                <select class="form-control" ng-model="b.room_name" ng-options="value.room_name+','+value.room_id as value.room_name for (key,value) in roomData[b.layer_name.split('+')[0]]">
                  <option value="">--请选择单元--</option>
                
                </select>
              </td>
              <td>
                <button class="btn btn-sm btn-rounded" ng-click="add()">添加</button>
              </td>
            </tr>           
          </table>

          <div style="font-weight: bold;font-size: 18px;" class="m-t">
            所选楼层
          </div>
          <table class="table">
              <tr>
                <th>学校</th>
                <th>类型</th>
                <th>楼号</th>
                <th>楼层</th>
                <th>单元</th>
                <th></th>
              </tr>
              <tr ng-repeat="aa in nn track by $index">
                <td>{{aa.school_name}}</td>
                <td  ng-if="aa.school_name!='所有学校'">{{aa.buildingtype}}</td>
                <td  ng-if="aa.school_name=='所有学校'">所有类型</td>
                <td ng-if="aa.school_name=='所有学校'||aa.buildingtype=='所有类型'">所有楼</td>
                <td ng-if="aa.school_name!='所有学校'&&aa.buildingtype!='所有类型'">{{aa.building_name}}</td>
                <td ng-if="aa.school_name=='所有学校'||aa.buildingtype=='所有类型'||aa.building_name=='所有楼'">所有层</td>              
                <td ng-if="aa.school_name!='所有学校'&&aa.buildingtype!='所有类型'&&aa.building_name!='所有楼'">{{aa.layer_name}}</td>
                <td ng-if="aa.school_name=='所有学校'||aa.buildingtype=='所有类型'||aa.building_name=='所有楼'||aa.layer_name=='所有层'">所有室</td>
                <td ng-if="aa.school_name!='所有学校'&&aa.buildingtype!='所有类型'&&aa.building_name!='所有楼'&&aa.layer_name!='所有层' ">{{aa.room_name}}</td>
                <td>
                  <button class="btn btn-xs btn-danger btn-rounded" ng-click="del('{{$index}}')">删除</button>
                </td>
              </tr>
          </table>         

      <div class="text-center">
        <button class="btn btn-rounded" ng-click="save()">保存</button>
      </div>
    </div>

  </div>
</div>
</div>


